@extends('layouts.app') @section('content')
<div class="container">
	<div class="row">
		<div class="col-md-10 col-md-offset-1 row">
			<div class="col-md-9">
				<img class="hot" src="/lv5/public/img/{{ $img }}" alt="">
				<ul id="index-articles">
					@foreach ($articles as $article)
					<li style="margin: 40px 0; list-style:none;">
						<div class="row">
							<div class="col-md-8 col-xs-7">
								@foreach ($article->hasManyUsers as $user)
								<img style="width: 32px; height:32px; border-radius: 16px;" src="/lv5/public/img/user/{{ $user->avatar }}" alt="">
								<span>{{ $user->name }}</span>&nbsp;&nbsp;&nbsp;&nbsp;
								<span>发表于&nbsp;&nbsp;{{ $article->created_at }}</span>
								@endforeach
								<div class="title">
								<h4><a class="article-title" href="{{ url('article/'.$article->id) }}">
										{{ $article->title }}
									</a></h4>
								</div>
								<div class="body">
									<p>{{ mb_substr($article->body, 0, 50).'...'}}</p>
								</div>
								<div>
									<a href=" {{ url('category').'?name='.$article->category }} ">
										<span class="category">{{ $article->category }}</span>
									</a>
									&nbsp;&nbsp;&nbsp;阅读&nbsp;
									<span>({{$article->read_total}})</span> &nbsp;&nbsp;&nbsp;回复&nbsp;
									<span>{{ $article->reply_total }}</span>
									&nbsp;&nbsp;&nbsp;点赞&nbsp;
									<span>{{ $article->upvote_total }}</span>
								</div>
							</div>
							<div class="col-md-4 col-xs-5">
								<a href="{{ url('article/'.$article->id) }}">
									<img class="img-responsive article-cover" src="/lv5/public/img/cover/{{$article->cover_img}}" alt="">
								</a>
							</div>
						</div>
					</li>
					<hr style="margin: 5px 0; width:100%; height:5px;"> @endforeach
				</ul>
			</div>
			<div class="col-md-3">
				<div class="page-title">推荐专题</div>
				<div class="page-category">
					@foreach ($categories as $category)
					<ul>
						<li>
							<img class="category-img" src="/lv5/public/img/category/{{ $category->category_img }}" alt="">
							<p class="category-message">
								<span>
									<strong>{{ $category->name }}</strong>
								</span>
								<br>
								<span style="color: #AAAAAA">文章 {{ $category->page_num }}</span>
							</p>
							<div class="page-button">
							<?php 
								$user_array = explode(',', $category->follower); 
							?> 
							@if (Auth::guest())
							<a href="{{ url('/login') }}" class="btn btn-primary btn-xs">+ 关注</a>
							@elseif ($category->founder == Auth::user()->id)
							<a class="btn btn-primary btn-xs" disabled>已关注</a>
							@else
							<?php $b = 1; ?> @foreach ($user_array as $user_id ) @if ($user_id == Auth::user()->no_id )
							<a href="{{ url('category/unfollow?category='.$category->id) }}" class="btn btn-primary btn-xs">已关注</a>
							<?php $b = 0; ?> @endif @endforeach @if($b == 1)
							<a href="{{ url('category/follow?category='.$category->id) }}" class="btn btn-primary btn-xs">+ 关注</a>
							@endif @endif
						</div>
						</li>
					</ul>
					@endforeach
				</div>
				<div class="page-title">推荐作家</div>
				<div>
					暂无…
				</div>
			</div>
		</div>
	</div>
</div>
@endsection